package com.atzqk.listener; /**
 * Date:2020/9/18
 * Author:ybc
 * Description:
 */

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionBindingEvent;

public class TestListener implements ServletContextListener{

    // Public constructor is required by servlet spec
    public TestListener() {
    }

    // -------------------------------------------------------
    // ServletContextListener implementation
    // -------------------------------------------------------
    public void contextInitialized(ServletContextEvent sce) {
        //获取ServletContext对象
        ServletContext servletContext = sce.getServletContext();
        //将上下文路径共享到整个工程中
        servletContext.setAttribute("PATH", servletContext.getContextPath());
    }

    public void contextDestroyed(ServletContextEvent sce) {

    }

}
